package concurrent.c_009_RefType;

import java.lang.ref.WeakReference;

/**
 * 弱引用遭到 gc 就会回收
 */
public class T03_WeakReference {
    public static void main(String[] args) {
        WeakReference<FinalizeMethod> m = new WeakReference<>(new FinalizeMethod());

        System.out.println(m.get());
        System.gc();
        System.out.println(m.get());


        ThreadLocal<FinalizeMethod> tl = new ThreadLocal<>();
        tl.set(new FinalizeMethod());
        tl.remove();
    }
}